import { createStore } from "vuex";

export default createStore({
  state: {
    loading: false, // loading动画
    token: null, // token存放
    userInfo: {}, // 用户信息存放
  },
  getters: {},
  mutations: {
    // 修改loading动画
    setLoading(state, value) {
      state.loading = value;
    },
    // 设置token
    setToken(state, data) {
      state.token = data;
    },
    // 删除token
    removeToken(state) {
      state.token = null;
    },
    // 设置用户信息
    setUserInfo(state, data) {
      state.userInfo = data;
    },
    // 删除用户信息
    removeUserInfo(state) {
      state.userInfo = {};
    },
  },
  actions: {},
  modules: {},
});
